<?php
class DmdformtypesController extends AppController {

	var $name = 'Dmdformtypes';
        function  beforeFilter() {
            parent::beforeFilter();
            $this->Auth->autoRedirect = false;
            switch ($this->Auth->user('group_id')){
                case 1:$this->Auth->allow('*');break;
                case 2:$this->Auth->deny('*');$this->Auth->allow('*');break;
                case 3:$this->Auth->deny('*');$this->Auth->allow($this->eicoArray);break;
                case 4:$this->Auth->deny('*');$this->Auth->allow($this->toolAdminArray);break;
                case 5:$this->Auth->deny('*');$this->Auth->allow($this->demanderArray);break;
                case 7:$this->Auth->deny('*');$this->Auth->allow($this->basicUserArray);break;
                case 6:$this->Auth->deny('*');$this->Auth->allow($this->requesterArray);break;
            }
            $this->set('active',3);
        }
	function index() {
		$this->Dmdformtype->recursive = 0;
		$this->set('dmdformtypes', $this->paginate());
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid dmdformtype', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->set('dmdformtype', $this->Dmdformtype->read(null, $id));
	}

	function add() {
		if (!empty($this->data)) {
			$this->Dmdformtype->create();
			if ($this->Dmdformtype->save($this->data)) {
				$this->Session->setFlash(__('The dmdformtype has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The dmdformtype could not be saved. Please, try again.', true));
			}
		}
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid dmdformtype', true));
			$this->redirect(array('action' => 'index'));
		}
		if (!empty($this->data)) {
			if ($this->Dmdformtype->save($this->data)) {
				$this->Session->setFlash(__('The dmdformtype has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The dmdformtype could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->Dmdformtype->read(null, $id);
		}
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for dmdformtype', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->Dmdformtype->delete($id)) {
			$this->Session->setFlash(__('Dmdformtype deleted', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->Session->setFlash(__('Dmdformtype was not deleted', true));
		$this->redirect(array('action' => 'index'));
	}
}
?>